//
//  NestedTypeViewController.swift
//  SwiftTest
//
//  Created by midea on 16/3/18.
//  Copyright © 2016年 Vincent. All rights reserved.
//

import Foundation
import UIKit

private class Star {
    var starName : String
    var planet : Planet?
    init(name : String){
        self.starName = name
    }
}

private class Planet {
    var planetName : String
    var state : State?
    init(name : String){
        self.planetName = name
    }
}

private class State {
    var stateName : String
    var country : Country?
    init(name : String){
        self.stateName = name
    }
}

private class Country {
    var countryName : String
    init(name : String){
        self.countryName = name
    }
}

class NestedTypeViewController : BaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.titles = ["statement"]
        self.tableView?.reloadData()
        
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        super.tableView(tableView, didSelectRowAt: indexPath)
        
        switch indexPath.row{
        case 0:
            statement()
        default:
            print("no more methods")
        }
    }
    
    fileprivate func statement(){
        let star = Star.init(name: "Sun")
        star.planet = Planet.init(name: "Earth")
        star.planet?.state = State.init(name: "Asia")
        star.planet?.state?.country = Country.init(name: "China")
        
        print(star.starName)
        print(star.planet?.planetName)
        print(star.planet?.state?.stateName)
        print(star.planet?.state?.country?.countryName)
    }
}
